package com.goldsprite.gesturerecognizer.core.utils;

import com.goldsprite.gesturerecognizer.core.GesturePoint;

public class GestureMathUtils {

	public static float calculateAngle(GesturePoint p1, GesturePoint p2) {
		float dx = p2.x - p1.x;
		float dy = p2.y - p1.y;
		return (float) Math.toDegrees(Math.atan2(dy, dx));
	}

	public static float normalizeAngle(float angle) {
		while (angle > 180) angle -= 360;
		while (angle < -180) angle += 360;
		return angle;
	}

	public static float distance(float x1, float y1, float x2, float y2) {
		float dx = x1 - x2;
		float dy = y1 - y2;
		return (float) Math.sqrt(dx * dx + dy * dy);
	}
}
